﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using System.Configuration;

namespace RMS.DataAccess.Common
{
    public  class ConnectionBase
    {
        protected DbProviderFactory _connectionType;
        private readonly string _connectionStringName;

        public ConnectionBase(string connectionStringName)
        {
            _connectionStringName = connectionStringName;
            _connectionType = DbProviderFactories.GetFactory(ConfigurationManager.ConnectionStrings[_connectionStringName].ProviderName);
        }
        protected DbConnection CreateConnection()
        {
            DbConnection connection = _connectionType.CreateConnection();
            connection.ConnectionString = ConfigurationManager.ConnectionStrings[_connectionStringName].ConnectionString;
            return connection;
        }
    }
}
